<script>
	export default {
		onLaunch: function() {
		    let that = this;
			let key = uni.getStorageSync('mini_sfshare_key');
			console.log("key: " + key)
			if (!key || key.length == 0) {
				uni.login({
					provider: 'weixin',
					success: function(loginRes) {
						if (loginRes.code) {
							uni.request({
								url: that.baseUrl + "/login",
								data: {
									code: loginRes.code
								},
								success(res) {
									if (res.statusCode == 200) {
										uni.setStorageSync('mini_sfshare_key', res.data.UUID_);
									} else {
										uni.showToast({
											icon: 'none',
											title: '未能获取用户信息，请稍后再试！',
											duration: 1200
										});
									}
								},
								fail(res) {
									uni.showToast({
										icon: 'none',
										title: '服务器开了小差，请稍后再试！',
										duration: 1200
									});
								}
							});
						} else {
							uni.showToast({
								icon: 'none',
								title: '登录失败! 请重新载入小程序！',
								duration: 1200
							});
						}
					}
				});
			}
		},
		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		}
	}
</script>

<style>
	/*每个页面公共css */
	@import "colorui/main.css";
	@import "colorui/icon.css";
</style>
